<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <%@ include file="/common/meta.jsp" %>
    <link rel="stylesheet" type="text/css" href="${ctx}/js/lib/validate/validate.css">
    <script type="text/javascript" src="${ctx}/js/lib/validate/jquery.validate.min.js"></script>
    <script type="text/javascript" src="${ctx}/js/lib/validate/jquery.validate.common_rules.js"></script>
    <script type="text/javascript" src="${ctx}/js/lib/validate/messages_cn.js"></script>
    <script type="text/javascript" src="${ctx}/js/gcu/rbac/user/edit.js"></script>
</head>
<body class="body_user_edit">
<ul class="breadcrumb">
    <li class="icon"></li>
    <li>您所在的位置：</li>
    <li>系统管理</li>
    <li>管理员管理</li>
    <li>管理员${empty id ? "新增" : "修改"}</li>
</ul>
<%@ include file="/common/top.jsp" %>
<div class="widget-content"id="_editDiv">
    <div >
        <form id="addFrom">
            <table class="table table">
                <tbody>
                <tr>
                    <th colspan="2" style="text-align:center;">用户信息：</th>
                    <input type="hidden" name="id" value="${user.id}">
                </tr>
                <tr>
                    <th class="th"><span class="point">*</span>登录姓名：</th>
                    <td class="pn-fcontent form-inline">
                        <c:if test="${user.id eq null}">
                            <input type="text" name="userName" class="form-control" value="${user.userName}"
                                   maxlength="25"/>
                        </c:if>
                        <c:if test="${user.id ne null}">
                            <input type="text" name="userName" class="form-control" value="${user.userName}"
                                   maxlength="25" disabled/>
                        </c:if>
                    </td>
                </tr>
                <c:if test="${user.id eq null}">
                <tr>
                    <th><span class="point">*</span>登录密码：</th>
                    <td class="pn-fcontent form-inline">
                        <input type="text" name="password" maxlength="50" class="form-control"
                               value="${user.password}"/>
                    </td>
                </tr>
                </c:if>
                        <input type="hidden" name="password" maxlength="50" class="form-control"
                               value="${user.password}"/>
                <tr>
                    <th><span class="point">*</span>真实姓名：</th>
                    <td class="pn-fcontent form-inline">
                        <input type="text" name="realName" maxlength="50" class="form-control"
                               value="${user.realName}"/>
                    </td>
                </tr>
                <tr>
                    <th><span class="point">*</span>账户状态：</th>
                    <td class="pn-fcontent form-inline">
                        <select name="status" id="status" class="form-control">
                            <c:if test="${user.id ne null}">
                                <c:if test="${user.status eq 0}">
                                    <option value="0">锁定</option>
                                    <option value="1">正常</option>
                                </c:if>
                                <c:if test="${user.status eq 1}">
                                    <option value="1">正常</option>
                                    <option value="0">锁定</option>
                                </c:if>
                            </c:if>
                            <c:if test="${user.id eq null}">
                                <option value="0">锁定</option>
                                <option value="1">正常</option>
                            </c:if>
                        </select>
                    </td>
                </tr>
                <tr>
                    <th><span class="point">*</span>电话号码：</th>
                    <td class="pn-fcontent form-inline">
                        <input type="text" name="phone" class="form-control" value="${user.phone}"
                               maxlength="25"/>
                    </td>
                </tr>
               <%-- <tr>
                    <th><span class="point">*</span>创建时间：</th>
                    <td class="pn-fcontent form-inline">
                        &lt;%&ndash; <input type="text" name="startTime" value="<@=chum.createTime@>" class="form-control" id="startDate"
                                onclick="WdatePicker({readOnly:true,dateFmt:'yyyy-MM-dd HH:mm:ss', maxDate:'#F{$dp.$D(\\\'endDate\\\')}'})"/>&ndash;%&gt;
                        &lt;%&ndash;<@= chum.createTime@>&ndash;%&gt;
                        <input type="text" name="createTime" class="form-control" value="${user.createTime}"
                               maxlength="25" disabled/>
                    </td>
                </tr>--%>
                <tr>
                    <th><span class="point">*</span>最后登录时间：</th>
                    <td class="pn-fcontent form-inline">
                        <input type="text" name="updateTime" class="form-control" value="${user.updateTime}"
                               maxlength="25" disabled/>
                    </td>
                </tr>
                <tr>
                    <th><span class="point">*</span>角色管理：</th>
                    <td class="pn-fcontent form-inline">
                        <c:forEach var="hr" items="${my_roles}">
                            <input type="hidden" class="hasRole" name="hasRole" value="${hr}"/>
                        </c:forEach>
                        <c:forEach items="${roleList}" var="roles">
                    <span class="label label-success" style="margin-left:5px">
                        ${roles.roleName} <input type="radio" name="rids" value="${roles.id}" class="rids">
                    </span>
                        </c:forEach>
                    </td>
                </tr>
                <tr>
                <tr>
                    <td class="pn-fcontent text-center" colspan="6">
                        <button type="submit" class="btn btn-info" id="saveBtn">保存</button>
                        <button type="button" class="btn btn-default" id="backBtn">返回</button>
                    </td>
                </tr>
            </table>
        </form>
    </div>
</div>
</body>
<script type="text/javascript">
    $(function () {
        var hasRoles = new Array();
        $(".hasRole").each(function () {
            hasRoles.push($(this).val());
        });
        $(".rids").each(function () {
            if ($.inArray($(this).val(), hasRoles) >= 0) {
                $(this).attr("checked", "checked");
            }
        });
    });
</script>
</html>